<?php

$StudentId = $_POST['StudentId'] ?? '';
$StudentName = $_POST['StudentName'] ?? '';
$StudentSex = $_POST['StudentSex'] ?? '';
$StudentBirth = $_POST['StudentBirth'] ?? '';
$StudentAddress = $_POST['StudentAddress'] ?? '';

// 修改班级id为$classId，他的信息为新的信息
$dsn = "sqlsrv:Server=LAPTOP-G184I03M\SQLEXPRESS;Database=Student";
$db = new PDO($dsn, "sa", "123456");

$sql = "update Student set StudentName='{$StudentName}', StudentSex='{$StudentSex}'
                   , StudentBirth='{$StudentBirth}', StudentAddress='{$StudentAddress}' where StudentId='{$StudentId}'";
$result = $db->exec($sql);
if ($result) {
    echo '修改成功，前往<a href="student_list.php">列表页</a>';
} else {
    echo '修改失败';
}